package com.sca.order.entity.api;

import com.sca.order.entity.enums.ResultEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * @author liuxianfei
 * @since 2020/10/30 10:59
 */
@Setter
@Getter
public class BaseResult<T> {

    /**
     * 状态码：0成功，其他为失败
     */
    public int code;

    /**
     * 返回信息
     */
    public String msg;

    /**
     * 数据结果集
     */
    public T data;

    public BaseResult() {
        this(ResultEnum.SUCCESS);
    }

    public BaseResult(T data) {
        this(ResultEnum.SUCCESS);
        this.data = data;
    }

    public BaseResult(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
    }

    public BaseResult(ResultEnum resultEnum, String msg) {
        this.code = resultEnum.getCode();
        this.msg = msg;
    }

}
